import type { App } from 'vue'
// 需要全局引入一些组件，如ElScrollbar，不然一些下拉项样式有问题
import { ElLoading, ElScrollbar, ElButton, ElTable, ElTableColumn } from 'element-plus'

const plugins = [ElLoading]

const components = [ElScrollbar, ElButton]

const TableProps = ElTable.props
const TableColumnProps = ElTableColumn.props


export const setupElementPlus = (app: App<Element>) => {
  plugins.forEach((plugin) => {
    app.use(plugin)
  })

  components.forEach((component) => {
    app.component(component.name, component)
  })

  TableProps.border = { type: Boolean, default: true }
  TableProps.showOverflowTooltip = { type: Boolean, default: true }
  TableProps.maxHeight = { type: Number, default: 500 }
  TableProps.headerCellStyle = { type: Object, default: () => ({ 'background-color': '#f5f7fa' }) }
  //TableProps.size = { type: String, default: 'small' }
  TableColumnProps.minWidth = { type: Number, default: 100 }
  TableColumnProps.align = { type: String, default: 'center' }
}
